home *** CD-ROM | disk | FTP | other *** search
- /*
-
- GTOVER -- GT Override
-
- Version 1.1 (4/14/89)
- Written by Bob Quinlan of Austin, TX, USA
-
- Copyright 1989 by Bob Quinlan
-
- Compatible with GT versions 13 and 14
-
-
- This program can be used to set up non-hierarchic security within GT.
- You can determine on a user-by-user basis who you want to have access to
- each file area, message area, and door. The program accomplishes this
- by modifying entries in GTDIR.BBS, GTMDIR.BBS, and GTDDIR.BBS to show
- the current user's access level. GT's normal security handles all users
- who are not listed in the override file. Normal security also applies
- to all areas and doors which are not specifically overridden.
-
- GTOVER normally gets its override information from a file called
- OVERRIDE.BBS. You can specify another file name on the command line if
- you prefer. You can also include a path as part of the filename. If no
- path is specified and the file is not in the default directory GTOVER
- will look in the GTPATH directory for it.
-
- You need to set the override file up as a text file containing user
- names and their associated security overrides. All usernames must start
- at the beginning of a line. Lines which begin with a space are assumed
- to be continuations of the previous user's information. The username
- must be immediately followed by a comma, semicolon, or carriage return.
- Overrides are specified by an initial letter followed by a number. The
- letters are "F" for file, "M" for message, and "D" for door. The number
- represents the file, message, or door number which is to be overridden.
- Any line in the corresponding security file which does not have a space
- in line one is counted as an entry. Overrides may be separated by
- spaces, commas, semicolons, or carriage returns.
-
- Here is a sample OVERRIDE.BBS:
-
- Bob Quinlan, F2 M6 M7 D4
- John Doe
- F3
- M5
-
- This file would give Bob Quinlan automatic access to the file area #2,
- message areas #6 and #7, and door #4 irregardless of the access level
- normally required. It would also give John Doe automatic access to file
- area #3 and message area #5.
-
- Special Note: This program will not give a user access to message areas
- from which they have been banned, nor will it override an asterisk
- specification on a message area. It simply alters the level of the
- areas so that they appear on the user's list.
-
- To use GTOVER you simply execute it in the GTLOGON.BAT. This will alter
- the security files as necessary for the current user. Make sure that
- you restore GTDIR.BBS, GTMDIR.BBS, and GTDDIR.BBS from unmodified copies
- during the GTLOGOFF.BAT. It is also a good idea to restore these files
- before starting GT so that special circumstances, such as a system
- reboot, will not compromise your security by leaving these files in
- their alterred states.
-
- NOTICE: You may use, copy, and distribute this program freely as long
- as you insure that both the executable and the documentation (.DOC)
- files are included in the distribution package. The source code does
- not need to be included. You may modify this program and document, so
- long as reasonable credit is given to the original author if a
- substantial portion of the original remains intact. The author is not
- responsible for any losses which may occur either directly or indirectly
- as a result of using this program.
-
- HISTORY:
- Version 1.1 (4/14/89) -- Handle cases where the access level is not
- the first character on a line. Accept a file
- specification for the override file from the
- command line.
- Version 1.0 (4/12/89) -- Original release. Written in Turbo C.
-
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <dos.h>
-
- #define MAXLINE 256
- #define MAXPATH 128
- #define PARAMS 8
-
- FILE *pathopen (char *, char *, char *);
-
-
- main (int argc, char *argv[])
-
- {
- char gtpath[MAXPATH];
-
- char fields[MAXLINE];
- char *gtuser[PARAMS];
- int arg;
-
- char data[MAXLINE];
- char line[MAXLINE];
-
- FILE *gtuser_fp;
- FILE *override_fp;
-
- FILE *fp[3];
- fpos_t pos;
- int cur_file;
- int count;
-
- char *token;
-
- int end_of_file = 0;
- int found = 0;
-
- int i, j, k;
-
- printf ("GTOVER 1.1 -- Copyright 1989 by Bob Quinlan (4/14/89)\n");
-
- /* Read and adapt GTPATH */
- strcpy (gtpath, getenv ("GTPATH"));
- i = strlen (gtpath);
- if (--i >= 0)
- if ((gtpath[i] != '\\') && (gtpath[i] != ':'))
- strcat (gtpath, "\\");
-
- /* Read in values from GTUSER.BBS */
- gtuser_fp = pathopen ("GTUSER.BBS", "r", gtpath);
- if (fgets (fields, MAXLINE, gtuser_fp) == NULL) {
- fprintf (stderr, "GTOVER: Unable to read GTUSER.BBS\n");
- exit (1);
- }
- fclose (gtuser_fp);
-
- /* Parse access level and name from GTUSER.BBS */
- arg = 0;
- gtuser[arg] = strtok (fields, " \n");
- while (!isupper (gtuser[arg][1]))
- gtuser[++arg] = strtok (NULL, " \n");
-
- /* Reassemble username into one string */
- for (i=2; i<arg; i++)
- *(gtuser[i]-1) = ' ';
-
- /* Search OVERRIDE.BBS for this user */
- if (argc > 1)
- override_fp = pathopen (argv[1], "r", gtpath);
- else
- override_fp = pathopen ("OVERRIDE.BBS", "r", gtpath);
- while (!end_of_file && !found)
- if (fgets (data, MAXLINE, override_fp) == NULL)
- end_of_file = 1;
- else
- if (*data != ' ') {
- token = strtok (data, ";,\n");
- if (strcmpi (gtuser[1], token) == 0)
- found = 1;
- }
-
- if (found) {
- fp[0] = pathopen ("GTDIR.BBS", "r+b", gtpath);
- fp[1] = pathopen ("GTMDIR.BBS", "r+b", gtpath);
- fp[2] = pathopen ("GTDDIR.BBS", "r+b", gtpath);
-
- while (found) {
- /* Parse file, message, and door overrides */
- token = strtok (NULL, " ;,\n");
- while ((token == NULL) && found)
- if (fgets (data, MAXLINE, override_fp) == NULL)
- found = 0;
- else
- /* Any line beginning with a space is a continuation */
- if (*data != ' ')
- found = 0;
- else
- token = strtok (data, " ;,\n");
- if (found) {
- *token = tolower (*token);
- if (*token == 'm')
- cur_file = 1;
- else if (*token == 'd')
- cur_file = 2;
- else
- cur_file = 0;
- if ((token = strpbrk (token, "0123456789")) == NULL)
- count = 1;
- else
- count = atoi (token);
-
- /* Read and modify */
- rewind (fp[cur_file]);
- i = 0;
- fgetpos (fp[cur_file], &pos);
- while ((fgets (line, MAXLINE, fp[cur_file]) != NULL) &&
- (i < count)) {
- if (*line != ' ')
- i++;
- if (i == count) {
- j = 0;
- k = strlen (line);
- while ((!isalnum(line[j++])) && (j < k))
- pos++;
- }
- else
- fgetpos (fp[cur_file], &pos);
- }
- if (i != count)
- fprintf (stderr, "GTOVER: Bad Override Specification\n");
- else {
- fsetpos (fp[cur_file], &pos);
- fputc (*gtuser[0], fp[cur_file]);
- }
- }
- }
-
- for (cur_file=2; cur_file>=0; cur_file--)
- fclose (fp[cur_file]);
- }
-
- fclose (override_fp);
-
- return 0;
- }
-
-
- /* Open file using GTPATH */
-
- FILE *pathopen (char *name, char *mode, char *gtpath) {
-
- FILE *fp;
-
- char path[MAXPATH];
-
- if ((fp = fopen (name, mode)) == NULL) {
- strcpy (path, gtpath);
- strcat (path, name);
- if ((fp = fopen (path, mode)) == NULL) {
- fprintf (stderr, "GTOVER: Unable to open %s\n", name);
- exit (1);
- }
- }
- return fp;
- }